Skip to content

Conversation

@Damans227
Copy link
Contributor

@Damans227 Damans227 commented Jan 12, 2026

Description

This PR fixes template upload error messages not being displayed in the UI. Previously, when template uploads failed (e.g., file format mismatch), the UI would show a generic "Request failed with status code 400" message instead of the actual error message from the SSVM (Secondary Storage VM).

Fixes: #11513

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

Broken:

image

Fixed:

Screenshot from 2026-01-12 17-20-18

How Has This Been Tested?

  1. Navigated to Templates → Upload Template
  2. Selected QCOW2 as format
  3. Uploaded a file with wrong format (e.g., RAW disk image, text file, or corrupted QCOW2)
  4. Verified error notification displays actual SSVM error message instead of generic "Request failed with status code 400"

@Damans227 Damans227 changed the title Improve error handling for template upload notifications UI: Improve error handling for template upload notifications Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.24%. Comparing base (8627c60) to head (a1df168).
⚠️ Report is 21 commits behind head on 4.20.

Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12412   +/-   ##
=========================================
  Coverage     16.24%   16.24%           
- Complexity    13378    13381    +3     
=========================================
  Files          5657     5657           
  Lines        498971   498973    +2     
  Branches      60561    60561           
=========================================
+ Hits          81033    81035    +2     
- Misses       408904   408905    +1     
+ Partials       9034     9033    -1     
Flag Coverage Δ
uitests 4.03% <ø> (-0.01%) ⬇️
unittests 17.09% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm. didn't test.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling for template upload failures by properly extracting and displaying error messages from the SSVM (Secondary Storage VM). Instead of showing a generic "Request failed with status code 400" message, the UI now displays the actual error message from the backend.

Changes:

  • Replaced custom error notification in template upload with $notifyError() utility
  • Refactored error message extraction logic to prioritize response headers and data over generic error messages

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ui/src/views/image/RegisterOrUploadTemplate.vue Simplified error handling to use $notifyError() utility
ui/src/utils/plugins.js Improved error message extraction logic to check response data before falling back to generic error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

desc = error.response.headers['x-description']
}
if (desc === '' && error.response.data) {
} else if (error.response.data) {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition check else if (error.response.data) is too broad and will evaluate to true for empty objects or arrays. This could lead to unnecessary processing of the response data block when there's no actual data. Consider using a more specific check like else if (error.response.data && Object.keys(error.response.data).length > 0) or checking for truthy values that actually contain data.

Suggested change
} else if (error.response.data) {
} else if (error.response.data && (typeof error.response.data !== 'object' || Object.keys(error.response.data).length > 0)) {

Copilot uses AI. Check for mistakes.
Comment on lines +227 to +228
} else if (typeof error.response.data === 'string') {
desc = error.response.data
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String responses should be trimmed before assignment to avoid displaying empty or whitespace-only error messages. Consider using desc = error.response.data.trim() and only assigning if the trimmed result is non-empty.

Copilot uses AI. Check for mistakes.
@RosiKyu
Copy link
Collaborator

RosiKyu commented Jan 21, 2026

@blueorangutan ui

@blueorangutan
Copy link

@RosiKyu a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/12412 (QA-JID-852)

@RosiKyu
Copy link
Collaborator

RosiKyu commented Jan 22, 2026

@blueorangutan package

@blueorangutan
Copy link

@RosiKyu a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16485

Copy link
Collaborator

@RosiKyu RosiKyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

TC1: Template Upload - Format Mismatch Error Message

Objective: Verify UI displays detailed error message when uploaded file format doesn't match selected format
Expected Result: UI shows descriptive error message with detected file type instead of generic "Request failed with status code 500"
Actual Result: Success - UI displays "File type mismatch between the sent file and the actual content. Received: PNG image data, 2402 x 1723, 8-bit/color RGBA, non-interlaced"
Test Evidence:

Screenshot from 2026-01-22 14-49-08

TC2: Valid Template Upload - Regression Test

Objective: Verify valid QCOW2 template uploads successfully after the fix (no regression)
Expected Result: Template uploads and becomes Ready
Actual Result: Success - Template uploaded successfully and shows Ready state
Test Evidence:

Screenshot from 2026-01-22 15-00-17 Screenshot from 2026-01-22 15-00-54

@DaanHoogland DaanHoogland merged commit bce3e54 into apache:4.20 Jan 22, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template upload shows generic "Request failed with status code 500" instead of actual error message

5 participants